import request from '@/utils/request'

export const getStaffAPI = data => request({
  url: '/sys/user',
  method: 'get',
  params: {
    page: data ? data.page : 1,
    size: data ? data.pageSize : 10
  }
})

export const addStaffAPI = data => request({
  url: '/sys/user',
  method: 'post',
  data
})

export const batchStaffAPI = data => request({
  url: '/sys/user/batch',
  method: 'post',
  data
})

export function delStaffAPI(id) {
  return request({
    url: `/sys/user/${id}`,
    method: 'delete'
  })
}

export function getStaffListAPI(id) {
  return request({
    url: `/sys/user/${id}`
  })
}

export function saveStaffListAPI(data) {
  return request({
    url: `/sys/user/${data.id}`,
    method: 'put',
    data
  })
}

// 详细信息表单
/** *
60	 *  读取用户详情的基础信息
61	 * **/
export function getPersonalDetail(id) {
  return request({
    url: `/employees/${id}/personalInfo`
  })
}

/** *
 *  更新用户详情的基础信息
 * **/
export function updatePersonal(data) {
  return request({
    url: `/employees/${data.userId}/personalInfo`,
    method: 'put',
    data
  })
}

/** **
 * 获取用户的岗位信息
 *
 * ****/
export function getJobDetailAPI(id) {
  return request({
    url: `/employees/${id}/jobs`
  })
}

/**
 * 保存岗位信息
 * ****/
export function updateJob(data) {
  return request({
    url: `/employees/${data.userId}/jobs`,
    method: 'put',
    data
  })
}
export function getEmployeeSimple() {
  return request({
    url: '/sys/user/simple'
  })
}
// 设置员工角色
export function assignRole(data) {
  return request({
    url: '/sys/user/assignRoles',
    method: 'put',
    data
  })
}
